<%@ page pageEncoding="UTF-8" contentType="text/html; charset=utf-8" isELIgnored="false" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="f" %>
<%
    request.setAttribute("path", request.getContextPath());
%>
<!DOCTYPE HTML>
<html>
<head>
    <title>图书详情</title>
    <link rel="stylesheet" type="text/css" href="${path }/front/css/book_detail.css"/>
    <link href="${path }/front/css/public_footer.css" rel="stylesheet" type="text/css"/>
    <script type="text/javascript">

        function imgChange(img) {
            img.src = "${path}/img/load.gif";


            var xhr;
            if (window.ActiveXObject) {
                xhr = new ActiveXObject('Microsoft.xmlhttp');
            } else {
                xhr = new XMLHttpRequest();
            }
            // 设置请求方式和请求目标
            xhr.open('get', '/order/order_ordermain?bookid=${book.id}');
            // 发送请求
            xhr.send();
            // 处理响应
            xhr.onreadystatechange = function () {
                if (xhr.readyState == 4 && xhr.status == 200) {
                    var json = xhr.responseText;
                    console.log(json);
                    // 将json字符串转换成js对象
                    var obj = JSON.parse(json);
                    console.log(obj)
                    //DOM编程
                }
                img.src = "${path}/img/right.gif";
                setTimeout(function () {
                    img.src = "${path }/front/images/buttom_goumai.gif";
                }, 1000);
            }


        }
    </script>

</head>
<body>
<br/>
<div>
    <h1>
        丛书名：${book.name}
    </h1>
    <hr/>
</div>
<table width="80%" border="0" align="center" cellspacing="0" cellpadding="5">
    <tr>
        <td rowspan="9" width="20%" valign="top"><img src="${path }/back/img/${book.cover}" width="240px"
                                                      height="340px"/></td>
        <td colspan="2">作者：${book.author}</td>
    </tr>
    <tr>
        <td colspan="2">出版社：${book.press }</td>
    </tr>
    <tr>
        <td>出版时间：<f:formatDate value="${book.press_date }" pattern="yyyy-MM-dd"/></td>
        <td>字数：${book.word_num }</td>
    </tr>
    <tr>
        <td>版次：${book.edition }</td>
        <td>页数：${book.page_num }</td>
    </tr>
    <tr>
        <td>印刷时间：<f:formatDate value="${book.print_date }" pattern="yyyy-MM-dd"/></td>
        <td>开本：${book.sizes }</td>
    </tr>
    <tr>
        <td>印次：${book.impression }</td>
        <td>纸张：${book.paper }</td>
    </tr>
    <tr>
        <td>ISBN：${book.isbn }</td>
        <td>包装：${book.pack }</td>
    </tr>
    <tr>
        <td colspan="2">定价：￥${book.price }&nbsp;&nbsp;&nbsp;&nbsp;
            <font color="red">当当价：￥${book.dprice }</font>&nbsp;&nbsp;&nbsp;&nbsp;
            节省：￥${book.price-book.dprice }</td>
        库存:${book.stock}/销量：${book.sale }
    </tr>
    <c:if test="${book.stock!=0}">
        <tr>
            <td colspan="2">
                    <%--<a href="${path}/order/order_ordermain?bookid=${book.id}">--%>
                <img src='${path }/front/images/buttom_goumai.gif' onclick="imgChange(this)"/>
                    <%--</a>--%>
            </td>
        </tr>
    </c:if>
    <c:if test="${book.stock==0}">
        <tr>
            <td colspan="2">
                <a href="#">
                    <img src='${path }/front/images/buttom_goumai.gif'/>
                </a>
            </td>
        </tr>
    </c:if>
</table>
<hr style="border:1px dotted #666"/>
<h2>编辑推荐:</h2>
<p>&nbsp;&nbsp;${book.editor_recommend }</p>
<hr style="border:1px dotted #666"/>
<h2>内容简介:</h2>
<p>${book.content_abstract }&nbsp;&nbsp;</p>
<hr style="border:1px dotted #666"/>
<h2>作者简介:</h2>
<p>${book.author_abstract }&nbsp;&nbsp;</p>
<hr style="border:1px dotted #666"/>
<h2>目录:</h2>
<p>${book.director }&nbsp;&nbsp;</p>
<hr style="border:1px dotted #666"/>
<h2>媒体评论:</h2>
<p>${book.media_commentary }&nbsp;&nbsp;</p>
<hr style="border:1px dotted #666"/>
<h2>书摘插图:</h2>
<p>&nbsp;&nbsp;</p>
<!--页尾开始 -->
<div class="public_footer">
    <div class="public_footer_bottom">
        <div class="public_footer_icp" style="line-height: 48px;">
            Copyright (C) 当当网 2004-2008, All Rights Reserved
            <a href="#" target="_blank"><img src="${path }/front/images/bottom/validate.gif" border="0" align="middle"/>
            </a>
            <a href="#" target="_blank" style="color: #666;">京ICP证041189号</a>
        </div>
    </div>
</div>
<!--页尾结束 -->
</body>
</html>
